﻿var webpack = require('webpack');
var path = require('path');
var fileCopy = require('copy-webpack-plugin');

var copyPlugin = new fileCopy(
    [
            //{ from: 'images', to: 'images' },       // copy all the images
            { from: 'index.html' },                 // copy index file 
            //{ from: 'modules', to: 'modules' }      // copy all html files
    ], {
        ignore: ['*.js', '*.map', '*.ts'],          // don't copy script files
        copyUnmodified: false                       // avoid redundant copy
    });

var srcPath = path.join(__dirname, 'app');
var entryPath = path.join(srcPath, 'entry.js');
var buildPath = path.resolve(__dirname, './dist');


module.exports = {
    resolve: { extensions: ['.ts', '.js'] },
    resolveLoader: { modules: ["node_modules"] },
    //devtool: 'source-map',

    context: srcPath,
    entry: entryPath,
    output: { path: buildPath, filename: 'bundle.js' },
    plugins: [ copyPlugin],
    module: {
        loaders: [
                        { test: /\.(woff|woff2|ttf|eot|svg)(\?]?.*)?$/, use: 'file-loader?name=fonts/[name].[ext]?[hash]' },
              { test: /\.html$/, use: 'raw-loader' },
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.(png|jpg)$/, use: 'url-loader?limit=8192&name=[path][name].[ext]' }, // inline base64 URLs for <=8k images, direct URLs for the rest
        ]
    }
};